<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <!--      使用连接的时候从根目录开始-->
    <base th:href="${#request.getContextPath() + '/'}">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="/vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"
          integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
    <!-- Google fonts - Popppins for copy-->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,800">
    <!-- orion icons-->
    <link rel="stylesheet" href="/css/orionicons.css">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="/css/custom.css">
    <!-- Favicon-->
    <link rel="shortcut icon" href="/img/favicon.png?3">
    <!-- Tweaks for older IEs--><!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
</head>
<style>
    .form-control-label {
        top: 10px;
        font-size: .9rem;
        color: #6c757d;
        padding-left: 180px;
    }
</style>
<body>


<!-- navbar-->
<div th:replace="publicheader::header"></div>
<div class="d-flex align-items-stretch">
    <div id="sidebar" class="sidebar py-3">
        <div class="text-gray-400 text-uppercase px-3 px-lg-4 py-4 font-weight-bold small headings-font-family">MAIN</div>
        <div th:replace="publicsidebar::sidebar"></div>
    </div>
    <div class="page-holder w-100 d-flex flex-wrap">
        <div class="container-fluid px-xl-5">

<!--上传文件-->
            <div class="col-lg-12 mb-5" style="margin-top: 30px;">
                <div class="card">
                    <div class="card-header">
                        <h6 class="text-uppercase mb-0">上传文件</h6>
                    </div>
                    <div class="card-body">
                        <form action="/classmaster/HSWorkBook" method="post"  enctype="multipart/form-data">
                            <input type="file" name="file"/>
                            <input type="submit"  id="button" class="btn btn-primary" style="float: right;margin-right: 44px;" th:value="上传">
                        </form>
                    </div>
                </div>
            </div>
<!--            学生展示,并下载-->
            <div class="col-lg-12 mb-5" style="margin-top: 30px;">
                <div class="card">
                    <div class="card-header">
                        <h6 class="text-uppercase mb-0">学生信息表</h6>
                    </div>
                    <div class="card-body">
                        <form action="#" method="get" onsubmit="return false">
                            <table class="table table-striped card-text">
                                <thead>
                                <tr>
                                    <th>
                                        <input type="checkbox" id="all" onclick="checkAllCart(this.checked)"/>
                                    </th>
                                    <th>序号</th>
                                    <th>姓名</th>
                                    <th>性别</th>
                                    <th>年龄</th>
                                    <th>地址</th>
                                    <th>电话</th>
                                    <th>班级</th>
                                    <th>
                                        <button type="submit" class="btn btn-primary" id="submits">下载</button>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="st:${student}">
                                    <th>
                                        <input type="checkbox" name="one" th:value="${st.stuId}"
                                               onclick="checkOneCart()"/>
                                    </th>
                                    <th th:text="${st.stuId}"></th>
                                    <th th:text="${st.stuName}"></th>
                                    <th th:text="${st.stuSex}"></th>
                                    <th th:text="${st.stuBirthday}"></th>
                                    <th th:text="${st.stuAddress}"></th>
                                    <th th:text="${st.stuPhone}"></th>
                                    <th th:text="${st.className}"></th>
                                    <th>&nbsp;</th>
                                </tr>
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div th:replace="publicfooter::footer"></div>
    </div>
</div>
<script>

    function checkAllCart(v) {
        var chOne = document.getElementsByName("one");
        //实现全选
        for (var i = 0; i < chOne.length; i++) {
            chOne[i].checked = v;
        }
    }

    //使用name判断all是否可以使用
    function checkOneCart() {
        var chOne = document.getElementsByName("one");
        var flag = true;
        for (var i = 0; i < chOne.length; i++) {
            if (!chOne[i].checked) {
                document.getElementById("all").checked = false;
                flag = false;
                break;
            }
            if (flag) {
                document.getElementById("all").checked = true;
            }
        }
    }

    // $("#button").click(function () {
    //     var file = $("#form_2").serialize();
    //     $.ajax({
    //         url:"/classmaster/HSWorkBook",
    //         date:file,
    //         type:"POST",
    //
    //     })
    // });


</script>
<script type="text/javascript">
    $("#submits").click(function () {
        var form = $("form").serialize();
        $.ajax({
            url: "/classmaster/getStudentInformtion",
            type: "POST",
            data: form,
            success: function (data) {
                if (data == "nihao") {
                    alert("以下载到桌面,请在桌面查找");
                }
            }
        });
    });
</script>

<footer class="footer bg-white shadow align-self-end py-3 px-xl-5 w-100" id="footerpage"></footer>
</div>
</div>
<!-- JavaScript files-->
<script src="/vendor/jquery/jquery.min.js"></script>
<script src="/vendor/popper.js/umd/popper.min.js"></script>
<script src="/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="/vendor/jquery.cookie/jquery.cookie.js"></script>
<script src="/vendor/chart.js/Chart.min.js"></script>
<script src="/js/js.cookie.min.js"></script>
<script src="/js/charts-custom.js"></script>
<script src="/js/front.js"></script>

</body>
</html>